package juc;

public class TestThread8Monitor {

    public static void main(String[] args) {
        Number number = new Number();

        new Thread(() -> number.getOne()).start();
        new Thread(() -> number.getTwo()).start();
        new Thread(() -> number.getThree()).start();
    }
}
class Number {

    public synchronized void getOne() {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("one");
    }

    public synchronized void getTwo() {
        System.out.println("two");
    }

    public void getThree() {
        System.out.println("three");
    }
}
